StripTags method replaces "&nbsp"   with at sign ("@")

Jane Chrom asked on July 20, 2022 11:40

I remove HTML tags from a string using the StripTags method. In one case, when the string contains the "&nbsp" character, the method replaces it with the "at" sign (@). Is there any other way to get rid of the tags and turn &nbsp to space?

and I use simply: description = HTMLHelper.StripTags(Model.Description); while Model.Description string is e.g.:

"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, « &nbsp sed do eiusmod &nbsp » tempor... </p>"

as a result I get:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, « @ sed do eiusmod @ » tempor...

Correct Answer

Brian McKeiver answered on July 23, 2022 17:01

&nbsp by itself may not be considered a real full HTML Entity (has to start with @ and end with ;. Can you try using &nbsp; ?

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.